package com.ctrip.ec.api.mobile.service.job;


import com.ctrip.ec.biz.dao.activity.ActivityDao;

import com.ctrip.ec.biz.dao.dict.DictDao;

import com.ctrip.ec.biz.entity.dict.DictCategory;
import com.ctrip.ec.biz.entity.dict.DictEntity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.sql.SQLException;


/**
 * Created by jiangzy on 2018/11/13.
 */
@Service
public class ActivityJob implements  Runnable{

    @Autowired
    private ActivityDao activity;

    @Autowired
    private DictDao dict;

    private static final Logger logger = LoggerFactory.getLogger(ActivityJob.class);

    @Override
    public void run() {
        try {
            //找到预告
            DictEntity src = dict.findByCode(DictCategory.activity_type.getCode(),"4");

            //找到直播
            DictEntity dest = dict.findByCode(DictCategory.activity_type.getCode(),"1");

            if(src != null && dest != null){
                activity.changeCategory(src,dest);
            }



        } catch (SQLException e) {

            logger.error(e.getMessage(),e);
        }

    }
}
